package com.exp06.Listener;

import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionEvent;
import jakarta.servlet.http.HttpSessionListener;

public class MySessionListener  implements HttpSessionListener {
    private int count =0 ;
    public void sessionCreated(HttpSessionEvent event){
        count++;
        event.getSession().getServletContext().setAttribute("onlineCount",count);
    }

    public void sessionDestroyed(HttpSessionEvent event) {
        count --;
        event.getSession().getServletContext().setAttribute("onlineCount",count);
    }
}
